<template>
	<view>
		<view class="item">

			<u-icon name="order" color="#1573FF" label="审核意见" label-color="#333333"
				:customStyle="{'line-height': '80rpx','display': 'block','padding-left':'20rpx',}"></u-icon>

			<u-line color="#efefef" :customStyle="{'margin-bottom': '10rpx','display': 'block',}"></u-line>

			<view style="margin: 20rpx;">
				<u-textarea v-model="approveContent" placeholder="请输入审核意见" height="150"></u-textarea>
			</view>

		</view>


		<view class="bottom">
			<text @click="commit">{{3==type?'审核驳回':4==type?'审核通过':1==type?'确认撤回':''}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				approveId: '',
				approveContent: '',
				processKey: '',
				exam_url: '',
				type: 0,
				bean: {

				}

			}
		},
		methods: {
			commit() {
				if(3==this.type){
					if(uni.$u.test.isEmpty(this.approveContent)){
						this.$u.toast('请输入驳回原因')
						return
					}
				}
				
				let that = this;

        // if(1==this.type){
        //   that.approveId = uni.$u.test.isEmpty(that.approveId)?'0':that.approveId
        // }
				
				uni.showModal({
					content:'确定提交吗?',
					success(res) {
						if(res.confirm){
							
							let addbean = {
								approveContent:that.approveContent,
								processKey:that.processKey,
								processOperationType:that.type,
								approveId:that.approveId,
								data:that.bean,
								
							}
							
							//执行提交
							that.$u.api.examflow(that.exam_url, addbean).then(res=>{
								that.$u.toast('提交成功')
                uni.$emit('approval', true)
								setTimeout(()=>{
									uni.navigateBack()
								}, 500)
							})
						}
					}
				})
			}
		},
		onLoad(op) {

			this.approveId = uni.$u.test.isEmpty(op.approveId)?'':op.approveId;
			this.processKey = uni.$u.test.isEmpty(op.processKey)?'':op.processKey;
			this.exam_url = uni.$u.test.isEmpty(op.url)?'':op.url;
			this.type = uni.$u.test.isEmpty(op.type)?'':op.type;
			this.bean = getApp().globalData.fix_exam_bean;

      console.log('aaa', this.approveId)

			getApp().globalData.fix_exam_bean = {}


			if (3 == this.type) {
				uni.setNavigationBarTitle({
					title: '审核驳回'
				})
			} else if (4 == this.type) {
				uni.setNavigationBarTitle({
					title: '审核通过'
				})
			} else if (1 == this.type) {
				uni.setNavigationBarTitle({
					title: '确认撤回'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.bottom {
		position: fixed;
		width: 100%;
		height: 100rpx;
		bottom: 0;
		z-index: 999;
		background-color: white;
		display: flex;
		align-items: center;
		justify-content: center;

		text {
			width: 98%;
			height: 80rpx;
			line-height: 80rpx;
			border-radius: 50rpx;
			background-color: $blue15;
			color: white;
			text-align: center;
			font-size: 30rpx;
		}
	}
</style>
